package io.github.consoles.distribution;

import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.Scanner;

/**
 * Created by yiihua-013 on 16/10/18.
 */
public class Evaluate {

    public static void main(String[] args) throws ScriptException {

        Scanner mScanner = new Scanner(System.in);
        System.out.println("输入一个数学计算表达式，如:1+2");
        String value_str = mScanner.nextLine();
        Double value_dou = (Double) new ScriptEngineManager().getEngineByName("js").eval(value_str);
        System.out.println(value_str + " = " + value_dou);
        mScanner.close();
    }
}
